home *** CD-ROM | disk | FTP | other *** search
/ Komputer for Alle 1999 #5 / 1999 CD 5 (black).iso / Delphi3 / install / data.z / IMAGEHLP.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-08-04  |  24.7 KB  |  574 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Delphi Run-time Library                         }
  4. {       Prototypes and constants required for the       }
  5. {       Win32 image help routines.                      }
  6. {                                                       }
  7. {       Copyright (c) 1996 Borland International        }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Imagehlp;
  12.  
  13. interface
  14.  
  15. uses Windows;
  16.  
  17. { Define checksum return codes. }
  18. const
  19.   CHECKSUM_SUCCESS                = 0;
  20.   CHECKSUM_OPEN_FAILURE           = 1; 
  21.   CHECKSUM_MAP_FAILURE            = 2;
  22.   CHECKSUM_MAPVIEW_FAILURE        = 3;
  23.   CHECKSUM_UNICODE_FAILURE        = 4;
  24.  
  25. { Define Splitsym flags. }
  26.  
  27.   SPLITSYM_REMOVE_PRIVATE         = $00000001;      { Remove CV types/symbols and Fixup debug }
  28. {  Used for creating .dbg files that ship }
  29. {  as part of the product. }
  30.  
  31.   SPLITSYM_EXTRACT_ALL            = $00000002;      { Extract all debug info from image. }
  32. {  Normally, FPO is left in the image }
  33. {  to allow stack traces through the code. }
  34. {  Using this switch is similar to linking }
  35. {  with -debug:none except the .dbg file }
  36. {  exists... }
  37.  
  38. { Define checksum function prototypes. }
  39. function CheckSumMappedFile(BaseAddress: Pointer; FileLength: DWORD;
  40.   HeaderSum: PDWORD; CheckSum: PDWORD): PImageNtHeaders; stdcall;
  41.  
  42. function MapFileAndCheckSumA(Filename: PAnsiChar; var HeaderSum,
  43.   CheckSum: DWORD): DWORD; stdcall;
  44. function MapFileAndCheckSumW(Filename: PWideChar; var HeaderSum,
  45.   CheckSum: DWORD): DWORD; stdcall;
  46. function MapFileAndCheckSum(Filename: PChar; var HeaderSum,
  47.   CheckSum: DWORD): DWORD; stdcall;
  48.  
  49.  
  50. function TouchFileTimes(FileHandle: THandle; const lpSystemTime: TSystemTime):
  51.   Bool; stdcall;
  52.  
  53. function SplitSymbols(ImageName, SymbolsPath, SymbolFilePath: LPSTR;
  54.   Flags: DWORD): Bool; stdcall;
  55.  
  56. function FindDebugInfoFile(FileName, SymbolPath, DebugFilePath: LPSTR): THandle; stdcall;
  57.  
  58. function FindExecutableImage(FileName, SymbolPath, ImageFilePath: LPSTR): THandle; stdcall;
  59.  
  60. function UpdateDebugInfoFile(ImageFileName, SymbolPath, DebugFilePath: LPSTR;
  61.   NtHeaders: PImageNtHeaders): Bool; stdcall;
  62.  
  63. function UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath: LPSTR;
  64.   NtHeaders: PImageNtHeaders; OldChecksum: DWORD): Bool; stdcall;
  65.  
  66. function BindImage(ImageName, DllPath, SymbolPath: LPSTR): Bool; stdcall;
  67.  
  68. type
  69.   TImagehlpStatusReason = (
  70.     BindOutOfMemory,
  71.     BindRvaToVaFailed,
  72.     BindNoRoomInImage,
  73.     BindImportModuleFailed,
  74.     BindImportProcedureFailed,
  75.     BindImportModule,
  76.     BindImportProcedure,
  77.     BindForwarder,
  78.     BindForwarderNOT,
  79.     BindImageModified,
  80.     BindExpandFileHeaders,
  81.     BindImageComplete,
  82.     BindMismatchedSymbols,
  83.     BindSymbolsNotUpdated
  84.   );
  85.  
  86. type
  87.   TImagehlpStatusRoutine = function(Reason: TImagehlpStatusReason;
  88.     ImageName, DllName: LPSTR; Va, Parameter: ULONG): Bool; stdcall;
  89.  
  90.  
  91. function BindImageEx(Flags: DWORD; ImageName, DllPath, SymbolPath: LPSTR;
  92.   var StatusRoutine: TImagehlpStatusReason): Bool; stdcall;
  93.  
  94. const
  95.   BIND_NO_BOUND_IMPORTS     = $00000001;
  96.   BIND_NO_UPDATE            = $00000002;
  97.   BIND_ALL_IMAGES           = $00000004;
  98.  
  99. function ReBaseImage(CurrentImageName, SymbolPath: LPSTR; fReBase,
  100.   fRebaseSysfileOk, fGoingDown: Bool; CheckImageSize: ULONG;
  101.   var OldImageSize, OldImageBase, NewImageSize, NewImageBase: ULONG;
  102.   TimeStamp: ULONG): Bool; stdcall;
  103.  
  104. const
  105.   IMAGE_SEPARATION     = 64 * 1024;
  106.  
  107. type
  108.   PloadedImage = ^LoadedImage;
  109.   LoadedImage = packed record
  110.     ModuleName: LPSTR;
  111.     hFile: THandle;
  112.     MappedAddress: PChar;
  113.     FileHeader: PImageNtHeaders;
  114.     LastRvaSection: PImageSectionHeader;
  115.     NumberOfSections: ULONG;
  116.     Sections: PImageSectionHeader;
  117.     Characteristics: ULONG;
  118.     fSystemImage: ByteBool;
  119.     fDOSImage: ByteBool;
  120.     Links: TListEntry;
  121.     SizeOfImage: ULONG;
  122.   end;
  123.  
  124.  
  125. function ImageLoad(DllName, DllPath: LPSTR): PLoadedImage; stdcall;
  126.  
  127. function ImageUnload(LoadedImage: PLoadedImage): Bool; stdcall;
  128.  
  129. function ImageNtHeader(Base: Pointer): PImageNtHeaders; stdcall;
  130.  
  131. function ImageDirectoryEntryToData(Base: Pointer; MappedAsImage: ByteBool;
  132.   DirectoryEntry: Word; var Size: ULONG): Pointer; stdcall;
  133.  
  134. function ImageRvaToSection(NtHeaders: PImageNtHeaders; Base: Pointer;
  135.   Rva: ULONG): PImageSectionHeader; stdcall;
  136.  
  137. function ImageRvaToVa(NtHeaders: PImageNtHeaders; Base: Pointer;
  138.   Rva: ULONG; var LastRvaSection: PImageSectionHeader): Pointer; stdcall;
  139.  
  140. function MapAndLoad(ImageName, DllPath: LPSTR; LoadedImage: PLoadedImage;
  141.   DotDll, ReadOnly: Bool): Bool; stdcall;
  142.  
  143. function GetImageConfigInformation(LoadedImage: PLoadedImage;
  144.   var ImageConfigInformation: TImageLoadConfigDirectory): Bool; stdcall;
  145.  
  146. function GetImageUnusedHeaderBytes(LoadedImage: PLoadedImage;
  147.   var SizeUnusedHeaderBytes: DWORD): DWORD; stdcall;
  148.  
  149. function SetImageConfigInformation(LoadedImage: PLoadedImage;
  150.   const ImageConfigInformation: TImageLoadConfigDirectory): Bool; stdcall;
  151.  
  152. function UnMapAndLoad(LoadedImage: PLoadedImage): Bool; stdcall;
  153.  
  154. type
  155.   PimageDebugInformation = ^TImageDebugInformation;
  156.   TImageDebugInformation = packed record
  157.     List: TListEntry;
  158.     Size: DWORD;
  159.     MappedBase: Pointer;
  160.     Machine: Word;
  161.     Characteristics: Word;
  162.     CheckSum: DWORD;
  163.     ImageBase: DWORD;
  164.     SizeOfImage: DWORD;
  165.     NumberOfSections: DWORD;
  166.     Sections: PImageSectionHeader;
  167.     ExportedNamesSize: DWORD;
  168.     ExportedNames: LPSTR;
  169.     NumberOfFunctionTableEntries: DWORD;
  170.     FunctionTableEntries: PImageFunctionEntry;
  171.     LowestFunctionStartingAddress: DWORD;
  172.     HighestFunctionEndingAddress: DWORD;
  173.     NumberOfFpoTableEntries: DWORD;
  174.     FpoTableEntries: PFpoData;
  175.     SizeOfCoffSymbols: DWORD;
  176.     CoffSymbols: PImageCOFFSymbolsHeader;
  177.     SizeOfCodeViewSymbols: DWORD;
  178.     CodeViewSymbols: Pointer;
  179.     ImageFilePath: LPSTR;
  180.     ImageFileName: LPSTR;
  181.     DebugFilePath: LPSTR;
  182.     TimeDateStamp: DWORD;
  183.     RomImage: Bool;
  184.     DebugDirectory: PImageDebugDirectory;
  185.     NumberOfDebugDirectories: DWORD;
  186.     Reserved: packed array[0..2] of DWORD;
  187.   end;
  188.  
  189. function MapDebugInformation(FileHandle: THandle; FileName, SymbolPath: LPSTR;
  190.   ImageBase: DWORD): PImageDebugInformation; stdcall;
  191.  
  192. function UnmapDebugInformation(DebugInfo: PImageDebugInformation): Bool; stdcall;
  193.  
  194. function SearchTreeForFile(RootPath, InputPathName, OutputPathBuffer: LPSTR):
  195.   Bool; stdcall;
  196.  
  197. function MakeSureDirectoryPathExists(DirPath: LPCSTR): Bool; stdcall;
  198.  
  199. { UnDecorateSymbolName Flags }
  200. const
  201.   UNDNAME_COMPLETE                     = $0000;    { Enable full undecoration }
  202.   UNDNAME_NO_LEADING_UNDERSCORES       = $0001;    { Remove leading underscores from MS extended keywords }
  203.   UNDNAME_NO_MS_KEYWORDS               = $0002;    { Disable expansion of MS extended keywords }
  204.   UNDNAME_NO_FUNCTION_RETURNS          = $0004;    { Disable expansion of return type for primary declaration }
  205.   UNDNAME_NO_ALLOCATION_MODEL          = $0008;    { Disable expansion of the declaration model }
  206.   UNDNAME_NO_ALLOCATION_LANGUAGE       = $0010;    { Disable expansion of the declaration language specifier }
  207.   UNDNAME_NO_MS_THISTYPE               = $0020;    { NYI Disable expansion of MS keywords on the 'this' type for primary declaration }
  208.   UNDNAME_NO_CV_THISTYPE               = $0040;    { NYI Disable expansion of CV modifiers on the 'this' type for primary declaration }
  209.   UNDNAME_NO_THISTYPE                  = $0060;    { Disable all modifiers on the 'this' type }
  210.   UNDNAME_NO_ACCESS_SPECIFIERS         = $0080;    { Disable expansion of access specifiers for members }
  211.   UNDNAME_NO_THROW_SIGNATURES          = $0100;    { Disable expansion of 'throw-signatures' for functions and pointers to functions }
  212.   UNDNAME_NO_MEMBER_TYPE               = $0200;    { Disable expansion of 'static' or 'virtual'ness of members }
  213.   UNDNAME_NO_RETURN_UDT_MODEL          = $0400;    { Disable expansion of MS model for UDT returns }
  214.   UNDNAME_32_BIT_DECODE                = $0800;    { Undecorate 32-bit decorated names }
  215.   UNDNAME_NAME_ONLY                    = $1000;    { Crack only the name for primary declaration; }
  216. {  return just [scope::]name.  Does expand template params }
  217.   UNDNAME_NO_ARGUMENTS                 = $2000;    { Don't undecorate arguments to function }
  218.   UNDNAME_NO_SPECIAL_SYMS              = $4000;    { Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc) }
  219.  
  220. function UnDecorateSymbolName(DecoratedName, UnDecoratedName: LPSTR;
  221.   UndecoratedLength, Flags: DWORD): DWORD; stdcall;
  222.  
  223.  
  224. { StackWalking API }
  225. type
  226.   TAddressMode = (
  227.     AddrMode1616,
  228.     AddrMode1632,
  229.     AddrModeReal,
  230.     AddrModeFlat
  231.   );
  232.  
  233.   PAddress = ^TAddress;
  234.   TAddress = packed record
  235.     Offset: DWORD;
  236.     Segment: Word;
  237.     Mode: TAddressMode;
  238.   end;
  239.  
  240. { This structure is included in the STACKFRAME structure, }
  241. { and is used to trace through usermode callbacks in a thread's }
  242. { kernel stack.  The values must be copied by the kernel debugger }
  243. { from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets. }
  244.  
  245.   PKdHelp = ^TKdHelp;
  246.   TKdHelp = packed record { address of kernel thread object, as provided }
  247.                           { in the WAIT_STATE_CHANGE packet. }
  248.     Thread: DWORD;
  249.     { offset in thread object to pointer to the current callback frame }
  250.     { in kernel stack. }
  251.     ThCallbackStack: DWORD;
  252.     { offsets to values in frame: }
  253.     { address of next callback frame }
  254.     NextCallback: DWORD;
  255.     { address of saved frame pointer (if applicable) }
  256.     FramePointer: DWORD;
  257.     { Address of the kernel function that calls out to user mode }
  258.     KiCallUserMode: DWORD;
  259.     { Address of the user mode dispatcher function }
  260.     KeUserCallbackDispatcher: DWORD;
  261.   end;
  262.  
  263.   PStackFrame = ^TStackFrame;
  264.   TStackFrame = packed record
  265.     AddrPC: TAddress;                  { program counter }
  266.     AddrReturn: TAddress;              { return address }
  267.     AddrFrame: TAddress;               { frame pointer }
  268.     AddrStack: TAddress;               { stack pointer }
  269.     FuncTableEntry: Pointer;          { pointer to pdata/fpo or NULL }
  270.     Params: packed array[0..3] of DWORD;{ possible arguments to the function }
  271.     _Far: Bool;                        { WOW far call }
  272.     _Virtual: Bool;                    { is this a virtual frame? }
  273.     Reserved: packed array[0..2] of DWORD;{ used internally by StackWalk api }
  274.     KdHelp: TKdHelp;
  275.   end;
  276.  
  277. type
  278.   TReadProcessMemoryRoutine = function(hProcess: THandle;
  279.     lpBaseAddress, lpBuffer: Pointer; nSize: DWORD;
  280.     var lpNumberOfBytesRead: DWORD): Bool; stdcall;
  281.  
  282.   TFunctionTableAccessRoutine = function(hProcess: THandle;
  283.     AddrBase: DWORD): Pointer; stdcall;
  284.  
  285.   TGetModuleBaseRoutine = function(hProcess: THandle;
  286.     ReturnAddress: DWORD): DWORD; stdcall;
  287.  
  288.   TTranslateAddressRoutine = function(hProcess, hThread: THandle;
  289.     lpaddr: PAddress): DWORD; stdcall;
  290.  
  291. function StackWalk(MachineType: DWORD; hProcess, hThread: THandle;
  292.   StackFrame: PStackFrame; ContextRecord: Pointer;
  293.   ReadMemoryRoutine: TReadProcessMemoryRoutine;
  294.   FunctionTableAccessRoutine: TFunctionTableAccessRoutine;
  295.   GetModuleBaseRoutine: TGetModuleBaseRoutine;
  296.   TranslateAddress: TTranslateAddressRoutine): Bool; stdcall;
  297.  
  298. const
  299.   API_VERSION_NUMBER     = 5;
  300.  
  301. type
  302.   PApiVersion = ^TApiVersion;
  303.   TApiVersion = packed record
  304.     MajorVersion: Word;
  305.     MinorVersion: Word;
  306.     Revision: Word;
  307.     Reserved: Word;
  308.   end;
  309.  
  310. function ImagehlpApiVersion: PApiVersion; stdcall;
  311.  
  312. function ImagehlpApiVersionEx(var AppVersion: TApiVersion): PApiVersion; stdcall;
  313.  
  314. function GetTimestampForLoadedLibrary(Module: HMODULE): DWORD; stdcall;
  315.  
  316. function RemovePrivateCvSymbolic(DebugData: PChar; var NewDebugData: PChar;
  317.   var NewDebugSize: ULONG): Bool; stdcall;
  318.  
  319. procedure RemoveRelocations(ImageName: PChar); stdcall;
  320.  
  321.  
  322. { typedefs for function pointers }
  323. type
  324.   TSymEnummodulesCallback = function(ModuleName: LPSTR; BaseOfDll: ULONG;
  325.     UserContext: Pointer): Bool; stdcall;
  326.  
  327.   TSymEnumsymbolsCallback = function(SymbolName: LPSTR; SymbolAddress,
  328.     SymbolSize: ULONG; UserContext: Pointer): Bool; stdcall;
  329.  
  330.   TEnumloadedModulesCallback = function(ModuleName: LPSTR; ModuleBase,
  331.     ModuleSize: ULONG; UserContext: Pointer): Bool; stdcall;
  332.  
  333.   TSymbolRegisteredCallback = function(hProcess: THandle; ActionCode: ULONG;
  334.     CallbackData, UserContext: Pointer): Bool; stdcall;
  335.  
  336.  
  337. { symbol flags }
  338. const
  339.   SYMF_OMAP_GENERATED       = $00000001;
  340.   SYMF_OMAP_MODIFIED        = $00000002;
  341.  
  342.  
  343. { symbol type enumeration }
  344. type
  345.   TSymType = (
  346.     SymNone,
  347.     SymCoff,
  348.     SymCv,
  349.     SymPdb,
  350.     SymExport,
  351.     SymDeferred,
  352.     SymSym                  { .sym file }
  353.   );
  354.  
  355. { symbol data structure }
  356.   PImagehlpSymbol = ^TImagehlpSymbol;
  357.   TImagehlpSymbol = packed record
  358.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_SYMBOL) }
  359.     Address: DWORD;                                     { virtual address including dll base address }
  360.     Size: DWORD;                                        { estimated size of symbol, can be zero }
  361.     Flags: DWORD;                                       { info about the symbols, see the SYMF defines }
  362.     MaxNameLength: DWORD;                               { maximum size of symbol name in 'Name' }
  363.     Name: packed array[0..0] of Char;                   { symbol name (null terminated string) }
  364.   end;
  365.  
  366.  
  367. { module data structure }
  368.   PImagehlpModule = ^TImagehlpModule;
  369.   TImagehlpModule = packed record
  370.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_MODULE) }
  371.     BaseOfImage: DWORD;                                 { base load address of module }
  372.     ImageSize: DWORD;                                   { virtual size of the loaded module }
  373.     TimeDateStamp: DWORD;                               { date/time stamp from pe header }
  374.     CheckSum: DWORD;                                    { checksum from the pe header }
  375.     NumSyms: DWORD;                                     { number of symbols in the symbol table }
  376.     SymType: TSymType;                                  { type of symbols loaded }
  377.     ModuleName: packed array[0..31] of Char;            { module name }
  378.     ImageName: packed array[0..255] of Char;            { image name }
  379.     LoadedImageName: packed array[0..255] of Char;      { symbol file name }
  380.   end;
  381.  
  382.  
  383. { data structures used for registered symbol callbacks }
  384. const
  385.   CBA_DEFERRED_SYMBOL_LOAD_START              = $00000001;
  386.   CBA_DEFERRED_SYMBOL_LOAD_COMPLETE           = $00000002;
  387.   CBA_DEFERRED_SYMBOL_LOAD_FAILURE            = $00000003;
  388.   CBA_SYMBOLS_UNLOADED                        = $00000004;
  389.   CBA_DUPLICATE_SYMBOL                        = $00000005;
  390.  
  391. type
  392.   PImagehlpDeferredSymbolLoad = ^TImagehlpDeferredSymbolLoad;
  393.   TImagehlpDeferredSymbolLoad = packed record
  394.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD) }
  395.     BaseOfImage: DWORD;                                 { base load address of module }
  396.     CheckSum: DWORD;                                    { checksum from the pe header }
  397.     TimeDateStamp: DWORD;                               { date/time stamp from pe header }
  398.     FileName: packed array[0..MAX_PATH-1] of Char;      { symbols file or image name }
  399.   end;
  400.  
  401.   PImagehlpDuplicateSymbol = ^TImagehlpDuplicateSymbol;
  402.   TImagehlpDuplicateSymbol = packed record
  403.     SizeOfStruct: DWORD;                                { set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL) }
  404.     NumberOfDups: DWORD;                                { number of duplicates in the Symbol array }
  405.     Symbol: PImagehlpSymbol;                            { array of duplicate symbols }
  406.     SelectedSymbol: ULONG;                           { symbol selected (-1 to start) }
  407.   end;
  408.  
  409.  
  410.  
  411. { options that are set/returned by SymSetOptions() & SymGetOptions() }
  412. { these are used as a mask }
  413.  
  414. const
  415.   SYMOPT_CASE_INSENSITIVE      = $00000001;
  416.   SYMOPT_UNDNAME               = $00000002;
  417.   SYMOPT_DEFERRED_LOADS        = $00000004;
  418.   SYMOPT_NO_CPP                = $00000008;
  419.  
  420.  
  421. function SymSetOptions(SymOptions: DWORD): DWORD; stdcall;
  422.  
  423. function SymGetOptions: DWORD; stdcall;
  424.  
  425. function SymCleanup(hProcess: THandle): Bool; stdcall;
  426.  
  427. function SymEnumerateModules(hProcess: THandle;
  428.   EnumModulesCallback: TSymEnumModulesCallback; UserContext: Pointer): Bool; stdcall;
  429.  
  430. function SymEnumerateSymbols(hProcess: THandle; BaseOfDll: DWORD;
  431.   EnumSymbolsCallback: TSymEnumSymbolsCallback; UserContext: Pointer): Bool; stdcall;
  432.  
  433. function EnumerateLoadedModules(hProcess: THandle;
  434.   EnumLoadedModulesCallback: TEnumLoadedModulesCallback;
  435.   UserContext: Pointer): Bool; stdcall;
  436.  
  437. function SymFunctionTableAccess(hProcess: THandle; AddrBase: DWORD): Pointer; stdcall;
  438.  
  439. function SymGetModuleInfo(hProcess: THandle; dwAddr: DWORD;
  440.   var ModuleInfo: TImagehlpModule): Bool; stdcall;
  441.  
  442. function SymGetModuleBase(hProcess: THandle; dwAddr: DWORD): DWORD; stdcall;
  443.  
  444. function SymGetSymFromAddr(hProcess: THandle; dwAddr: DWORD;
  445.   pdwDisplacement: PDWORD; var Symbol: TImagehlpSymbol): Bool; stdcall;
  446.  
  447. function SymGetSymFromName(hProcess: THandle; Name: LPSTR;
  448.   var Symbol: TImagehlpSymbol): Bool; stdcall;
  449.  
  450. function SymGetSymNext(hProcess: THandle; var Symbol: TImagehlpSymbol): Bool; stdcall;
  451.  
  452. function SymGetSymPrev(hProcess: THandle; var Symbol: TImagehlpSymbol): Bool; stdcall;
  453.  
  454. function SymInitialize(hProcess: THandle; UserSearchPath: LPSTR;
  455.   fInvadeProcess: Bool): Bool; stdcall;
  456.  
  457. function SymGetSearchPath(hProcess: THandle; SearchPath: LPSTR;
  458.   SearchPathLength: DWORD): Bool; stdcall;
  459.  
  460. function SymSetSearchPath(hProcess: THandle; SearchPath: LPSTR): Bool; stdcall;
  461.  
  462. function SymLoadModule(hProcess: THandle; hFile: THandle; ImageName,
  463.   ModuleName: LPSTR; BaseOfDll, SizeOfDll: DWORD): Bool; stdcall;
  464.  
  465. function SymUnloadModule(hProcess: THandle; BaseOfDll: DWORD): Bool; stdcall;
  466.  
  467. function SymUnDName(sym: PImagehlpSymbol; UnDecName: LPSTR;
  468.   UnDecNameLength: DWORD): Bool; stdcall;
  469.  
  470. function SymRegisterCallback(hProcess: THandle;
  471.   CallbackFunction: TSymbolRegisteredCallback; UserContext: Pointer): Bool; stdcall;
  472.  
  473. { Image Integrity API's }
  474.  
  475. const
  476.   CERT_PE_IMAGE_DIGEST_DEBUG_INFO             = $01;
  477.   CERT_PE_IMAGE_DIGEST_RESOURCES              = $02;
  478.   CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO        = $04;
  479.  
  480.   CERT_SECTION_TYPE_ANY                       = $FF;      { Any Certificate type }
  481.  
  482. type
  483.   TDigestHandle = Pointer;
  484.  
  485. type
  486.   TDigestFunction = function(refdata: TDigestHandle; pData: PByte;
  487.     dwLength: DWORD): Bool; stdcall;
  488.  
  489. function ImageGetDigestStream(FileHandle: THandle; DigestLevel: DWORD;
  490.   DigestFunction: TDigestFunction; DigestHandle: TDigestHandle): Bool; stdcall;
  491.  
  492. function ImageAddCertificate(FileHandle: THandle;
  493.   var Certificate: PWinCertificate; var Index: DWORD): Bool; stdcall;
  494.  
  495. function ImageRemoveCertificate(FileHandle: THandle; Index: DWORD): Bool; stdcall;
  496.  
  497. function ImageEnumerateCertificates(FileHandle: THandle; TypeFilter: Word;
  498.   CertificateCount, Indices, IndexCount: PDWORD): Bool; stdcall;
  499.  
  500. function ImageGetCertificateData(FileHandle: THandle; CertificateIndex: DWORD;
  501.   Certificate: PWinCertificate; var RequiredLength: DWORD): Bool; stdcall;
  502.  
  503. function ImageGetCertificateHeader(FileHandle: THandle; CertificateIndex: DWORD;
  504.   var Certificateheader: PWinCertificate): Bool; stdcall;
  505.  
  506. implementation
  507.  
  508. const
  509.   ImagehlpLib = 'IMAGEHLP.DLL';
  510.  
  511. function BindImage;                     external ImagehlpLib name 'BindImage';
  512. function BindImageEx;                   external ImagehlpLib name 'BindImageEx';
  513. function CheckSumMappedFile;            external ImagehlpLib name 'CheckSumMappedFile';
  514. function EnumerateLoadedModules;        external ImagehlpLib name 'EnumerateLoadedModules';
  515. function FindDebugInfoFile;             external ImagehlpLib name 'FindDebugInfoFile';
  516. function FindExecutableImage;           external ImagehlpLib name 'FindExecutableImage';
  517. function GetImageConfigInformation;     external ImagehlpLib name 'GetImageConfigInformation';
  518. function GetImageUnusedHeaderBytes;     external ImagehlpLib name 'GetImageUnusedHeaderBytes';
  519. function GetTimestampForLoadedLibrary;  external ImagehlpLib name 'GetTimestampForLoadedLibrary';
  520. function ImageAddCertificate;           external ImagehlpLib name 'ImageAddCertificate';
  521. function ImageDirectoryEntryToData;     external ImagehlpLib name 'ImageDirectoryEntryToData';
  522. function ImageEnumerateCertificates;    external ImagehlpLib name 'ImageEnumerateCertificates';
  523. function ImageGetCertificateData;       external ImagehlpLib name 'ImageGetCertificateData';
  524. function ImageGetCertificateHeader;     external ImagehlpLib name 'ImageGetCertificateHeader';
  525. function ImageGetDigestStream;          external ImagehlpLib name 'ImageGetDigestStream';
  526. function ImagehlpApiVersion;            external ImagehlpLib name 'ImagehlpApiVersion';
  527. function ImagehlpApiVersionEx;          external ImagehlpLib name 'ImagehlpApiVersionEx';
  528. function ImageLoad;                     external ImagehlpLib name 'ImageLoad';
  529. function ImageNtHeader;                 external ImagehlpLib name 'ImageNtHeader';
  530. function ImageRemoveCertificate;        external ImagehlpLib name 'ImageRemoveCertificate';
  531. function ImageRvaToSection;             external ImagehlpLib name 'ImageRvaToSection';
  532. function ImageRvaToVa;                  external ImagehlpLib name 'ImageRvaToVa';
  533. function ImageUnload;                   external ImagehlpLib name 'ImageUnload';
  534. function MakeSureDirectoryPathExists;   external ImagehlpLib name 'MakeSureDirectoryPathExists';
  535. function MapAndLoad;                    external ImagehlpLib name 'MapAndLoad';
  536. function MapDebugInformation;           external ImagehlpLib name 'MapDebugInformation';
  537. function MapFileAndCheckSumA;           external ImagehlpLib name 'MapFileAndCheckSumA';
  538. function MapFileAndCheckSumW;           external ImagehlpLib name 'MapFileAndCheckSumW';
  539. function MapFileAndCheckSum;           external ImagehlpLib name 'MapFileAndCheckSumA';
  540. function ReBaseImage;                   external ImagehlpLib name 'ReBaseImage';
  541. function RemovePrivateCvSymbolic;       external ImagehlpLib name 'RemovePrivateCvSymbolic';
  542. procedure RemoveRelocations;            external ImagehlpLib name 'RemoveRelocations';
  543. function SearchTreeForFile;             external ImagehlpLib name 'SearchTreeForFile';
  544. function SetImageConfigInformation;     external ImagehlpLib name 'SetImageConfigInformation';
  545. function SplitSymbols;                  external ImagehlpLib name 'SplitSymbols';
  546. function StackWalk;                     external ImagehlpLib name 'StackWalk';
  547. function SymCleanup;                    external ImagehlpLib name 'SymCleanup';
  548. function SymEnumerateModules;           external ImagehlpLib name 'SymEnumerateModules';
  549. function SymEnumerateSymbols;           external ImagehlpLib name 'SymEnumerateSymbols';
  550. function SymFunctionTableAccess;        external ImagehlpLib name 'SymFunctionTableAccess';
  551. function SymGetModuleBase;              external ImagehlpLib name 'SymGetModuleBase';
  552. function SymGetModuleInfo;              external ImagehlpLib name 'SymGetModuleInfo';
  553. function SymGetOptions;                 external ImagehlpLib name 'SymGetOptions';
  554. function SymGetSearchPath;              external ImagehlpLib name 'SymGetSearchPath';
  555. function SymGetSymFromAddr;             external ImagehlpLib name 'SymGetSymFromAddr';
  556. function SymGetSymFromName;             external ImagehlpLib name 'SymGetSymFromName';
  557. function SymGetSymNext;                 external ImagehlpLib name 'SymGetSymNext';
  558. function SymGetSymPrev;                 external ImagehlpLib name 'SymGetSymPrev';
  559. function SymInitialize;                 external ImagehlpLib name 'SymInitialize';
  560. function SymLoadModule;                 external ImagehlpLib name 'SymLoadModule';
  561. function SymRegisterCallback;           external ImagehlpLib name 'SymRegisterCallback';
  562. function SymSetOptions;                 external ImagehlpLib name 'SymSetOptions';
  563. function SymSetSearchPath;              external ImagehlpLib name 'SymSetSearchPath';
  564. function SymUnDName;                    external ImagehlpLib name 'SymUnDName';
  565. function SymUnloadModule;               external ImagehlpLib name 'SymUnloadModule';
  566. function TouchFileTimes;                external ImagehlpLib name 'TouchFileTimes';
  567. function UnDecorateSymbolName;          external ImagehlpLib name 'UnDecorateSymbolName';
  568. function UnMapAndLoad;                  external ImagehlpLib name 'UnMapAndLoad';
  569. function UnmapDebugInformation;         external ImagehlpLib name 'UnmapDebugInformation';
  570. function UpdateDebugInfoFile;           external ImagehlpLib name 'UpdateDebugInfoFile';
  571. function UpdateDebugInfoFileEx;         external ImagehlpLib name 'UpdateDebugInfoFileEx';
  572.  
  573. end.
  574.